package com.ptu.spzx.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ptu.spzx.domain.Stu.StuAnswer;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author YT
 * @since 2024-01-28
 */
@Mapper
public interface StuAnswerMapper extends BaseMapper<StuAnswer> {

    @Select("SELECT * FROM stu_answer WHERE stu_id=#{stuId} AND is_delete=0")
    StuAnswer selectByStuId(String stuId);

    @Select("SELECT * FROM stu_answer WHERE stu_id=#{stuId} AND ep_id=#{epId} AND is_delete=0")
    StuAnswer selectByStuIdByEpId(String stuId,Long epId);


    @Select("SELECT * from stu_answer WHERE stu_id=#{randomNStuId} and exam_id=#{examId} AND is_delete=0")
    StuAnswer SelectByStuIdAndExamId(String randomNStuId, Long examId);

    @Update("update stu_answer set stu_scorelist=#{stuScorelist},stu_score=#{stuScore},system_score=#{systemScore},ep_status=3 where stu_id=#{stuId} and ep_id=#{epId} and exam_id=#{examId}")
    Integer UpdateStuScore(Map<String, Object> params);

    @Update("update stu_answer set ep_status=2 WHERE stu_id=#{stuId}")
    Integer updateEpStatus(String stuId);
}
